<link rel="stylesheet" href="<%- Virtual_Path.Static %>main/css/lib/bootstrap/css//bootstrap.min.css"/>
<link rel="stylesheet" href="<%- Virtual_Path.Static %>main/css/lib/bootstrap/css/bootstrap-theme.min.css"/>
<link rel="stylesheet" href="<%- Virtual_Path.Static %>main/css/entry-apply.css"/>
<div class="xiu-container">
    <div class="apply-wrap" id="j-yr-apply">
        <h1 class="app-tit">公会申请入驻</h1>
        <!--进度步骤导航-->
        <div class="apply-step family-apply-step clearfix">
            <ul class="progress-step-nav">
                <li><a href="javascript:;"><i>1</i>创造条件</a></li>
                <li class="active"><a href="javascript:;"><i>2</i>个人资料</a></li>
                <li><a href="javascript:;"><i>3</i>财务信息</a></li>
                <li><a href="javascript:;"><i>4</i>完成</a></li>
            </ul>
        </div>

        <!-- 进度步骤-->
        <div class="progress-step-cont">
            <div class="step-cont-outer">
                <div class="step-cont-inner">
                    <div class="step-cont-mod step-1">
                        <form class="form-horizontal">
                            <div class="form-group">
                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">申请入驻账号</label>
                                    <div class="col-sm-10" >
                                        <p class="form-control-static" id="J_FamilyNickName_Info">-</p>
                                    </div>
                                </div>
                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">公会名称</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control"  placeholder="" name="Family_Name" id="J_Family_Name" value="">
                                    </div>
                                </div>
                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">联系人姓名</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control" name="RealName"  placeholder="" id="J_Family_RealName" value="">
                                    </div>
                                    <div class="col-sm-5" >
                                        <p>（请填写您本人真实姓名，同时真实姓名与身份证及银行卡户名请保持一致）</p>
                                    </div>
                                </div>
                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">手机号码</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control"  placeholder="" name="Phone" id="J_Family_Phone" value="">
                                    </div>
                                </div>

                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">QQ</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control"  placeholder="" name="QQ">
                                    </div>
                                </div>

                                <div class="col-xs-8 form-group">
                                    <label for="" class="col-sm-2 control-label">邮箱</label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control"  placeholder="" name="Email" value="" id="J_Family_Email">
                                    </div>
                                </div>

                                <div class="col-xs-8 form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                        <button class="btn btn-primary" type="button" id="step-s1">下一步</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        ////////////////////////////////////
        //判断是否登录或者是否申请艺人或公会
        ////////////////////////////////////
        if(_StateData.IsFamily){
            $.CommonMain.Modal_Tip('你已经申请了公会，无需申请了', {
                Timeout: 1000,
                onClose: function () {
                    location.href = "/";
                }
            });
        }
        if(_PageData.flag==2){
            $.CommonMain.Modal_Tip(_PageData.message, {
                Timeout: 2000,
                onClose: function () {
                    location.href = "/";
                }
            });
        }
        ////////////////////////////////////
        //赋值
        ////////////////////////////////////
        var SexInfo = '';
        //真实姓名
        if (_StateData.RealName){
            $('#J_Family_RealName').attr('value',  _StateData.RealName );
        }
        //昵称
        if (_StateData.NickName) {
            $("#J_FamilyNickName_Info").text(_StateData.NickName);
        }
        //手机号
        if (_PageData.UserInfo.Phone) {
            $("#J_Family_Phone").attr('value',_PageData.UserInfo.Phone);
        }
        //email
        if (_PageData.UserInfo.Email) {
            $("#J_Family_Email").attr('value', _PageData.UserInfo.Email);
        }
        $("#step-s1").on("click", function () {
            var params = {};
            var tel = /^0?(13[0-9]|15[012356789]|18[0123456789]|17[0123456789]|14[57])[0-9]{8}$|^[a-zA-Z0-9][a-zA-Z0-9._-]*\@[a-zA-Z0-9]+\.[a-zA-Z0-9\.]+$/;
            var email = /^[a-zA-Z0-9][a-zA-Z0-9._-]*\@[a-zA-Z0-9]+\.[a-zA-Z0-9\.]+$/;
            params.RealName = $.trim($('input[name="RealName"]').val());//真实姓名
            params.Family_Name = $.trim($('input[name="Family_Name"]').val());//公会名称
            params.Phone = $.trim($('input[name="Phone"]').val());//手机号
            params.QQ = $.trim($('input[name="QQ"]').val());//qq号
            params.Email = $.trim($('input[name="Email"]').val());//email
            if (!params.RealName) {
                $.CommonMain.Modal_Tip('请输入真实姓名', {Timeout: 1000});
                $('input[name="RealName"]').focus();
                return false;
            }
            if (!params.Family_Name) {
                $.CommonMain.Modal_Tip('请输入公会名称！', {Timeout: 1000});
                $('input[name="Family_Name"]').focus();
                return false;
            }
            if (!params.Phone) {
                $.CommonMain.Modal_Tip('请输入联系人手机号', {Timeout: 1000});
                $('input[name="Phone"]').focus();
                return false;
            } else if (!tel.test(params.Phone)) {
                $.CommonMain.Modal_Tip('你输入的联系人手机号格式不正确', {Timeout: 1000});
                $('input[name="Phone"]').focus();
                return false;
            }
            if (!params.QQ) {
                $.CommonMain.Modal_Tip('请输入联系人qq', {Timeout: 1000});
                $('input[name="QQ"]').focus();
                return false;
            }
            if (!params.Email) {
                $.CommonMain.Modal_Tip('请输入联系人email邮箱', {Timeout: 1000});
                $('input[name="Email"]').focus();
                return false;
            }
            if (!email.test(params.Email)) {
                $.CommonMain.Modal_Tip('您输入的联系人email格式不正确,请重新输入', {Timeout: 1000});
                $('input[name="Email"]').focus();
                return false;
            }
            $.KOC.Loading.Open();
            $.ajax({
                url: '/ajax/business.user-familyapply.stepone',
                type: 'post',
                dataType: 'json',
                data: {
                    ContactName: params.RealName,
                    Family_Name:params.Family_Name,
                    Phone: params.Phone,
                    QQ: params.QQ,
                    Email: params.Email
                },
                success: function (data) {
                    $.KOC.Loading.Close();
                    if (data.flag !== 0) {
                        $.CommonMain.Modal_Tip(data.msg + "(" + data.flag + ")", {Timeout: 2000});
                        return;
                    }
                    location.href = "/entry/family/step_3";
                }
            });
        });
    })

</script>